package lhdmn;
import java.util.ArrayList;
import java.util.List;
// 顾客类
class Customer {
    private String name;
    private String phone;

    public Customer(String name, String phone) {
        this.name = name;
        this.phone = phone;
    }

    // Getter方法
    public String getName() { return name; }
    public String getPhone() { return phone; }
}

// 订单类
class Order {
    private Customer customer;
    private List<Dish> dishList;
    private double totalPrice;
    private String orderId;

    public Order(Customer customer, String orderId) {
        this.customer = customer;
        this.dishList = new ArrayList<>();
        this.totalPrice = 0;
        this.orderId = orderId;
    }

    // 添加菜品到订单
    public void addDish(Dish dish) throws Exception {
        if (!dish.isOnSale()) {
            throw new Exception("菜品" + dish.getName() + "已下架，无法点餐！");
        }
        if (dish.getStock() <= 0) {
            throw new Exception("菜品" + dish.getName() + "库存不足，无法点餐！");
        }
        dishList.add(dish);
        totalPrice += dish.getPrice();
    }

    // 计算总价
    public double calculateTotal() {
        return totalPrice;
    }

    // Getter方法
    public List<Dish> getDishList() { return dishList; }
    public double getTotalPrice() { return totalPrice; }
    public String getOrderId() { return orderId; }
}